import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import com.titan.domain.Cabin;
import com.titan.domain.Customer;

public class Main {
	public static void main(String[] args) {
		EntityManagerFactory factory = Persistence
				.createEntityManagerFactory("TitanDomain");
		EntityManager em = factory.createEntityManager();

		em.getTransaction().begin();
		
		Cabin c = new Cabin();
		c.setBedCount(50);
		c.setDeckLevel(2);
		c.setName("Cabin111");
		c.setShipId(0);
		
		em.persist(c);
		System.out.println(em.contains(c));
		Cabin b = em.find(Cabin.class, 1);
		System.out.println(b.getName());
		
		
		Customer cust = new Customer();
		cust.setFirstName("firstName");
		cust.setLastName("lastName");
		em.persist(cust);
		
		System.out.println( cust.getId() );
		cust = new Customer();
		cust.setFirstName("firstName2");
		cust.setLastName("lastName2");
		em.persist(cust);
		System.out.println( cust.getId() );
		
		em.getTransaction().commit();
		em.close();
		factory.close();
	}

}